package com.example.orderminiappapi.config;

import com.example.orderminiappapi.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


// 编写一个拦截器Interceptor,然后将其注册到容器中,指定拦截规则(如果是拦截所有,静态资源也会被拦截)
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/getOpenid",
                        "/addNewShopOwner",
                        "/signIn",
//                        "/uploadImg",
                        "/css/**",
                        "/fonts/**",
                        "/images/**",
                        "/js/**",
                        "/static/**"
                );  //配置要拦截的请求和不要拦截的请求
        //静态资源也会被默认拦截
    }
}
